<template>
  <!-- 快速登记 -->
  <section>
    <el-form :inline="true" @submit.native.prevent="getData(-1)">
      <el-form-item style="margin-bottom:0;">
        <deptSearch v-model="form.deptId" @change="onChangeDept"></deptSearch>
      </el-form-item>
      <el-form-item style="margin-bottom:0;">
        <doctorSearch ref="doctorSearch" v-model="form.doctorId" :deptId="form.deptId"></doctorSearch>
      </el-form-item>
      <el-form-item style="margin-bottom:0;">
        <el-button type="primary" native-type="submit" circle icon="el-icon-search"></el-button>
      </el-form-item>
    </el-form>
    <br>
    <h3>当前全部坐诊医生</h3>
    <el-row :gutter="20">
      <el-col v-for="(item,index) in tableList" :key="index" :xs="12" :sm="12" :md="12" :lg="8" :xl="6" class="reserve-user-list">
        <div class="card-box bg-jzz">
          <div class="card-nr">
            <div>
              <img v-if="!item.head" src="@/img/unknown-avatar.png" class="head-img" alt="" style="width:70px;height:70px;">
              <img v-else :src="item.head|imageUrl" class="head-img" alt="" style="width:70px;height:70px;">
            </div>
            <div style="overflow: hidden;">
              <p class="overflow-omit">
                <span style="font-size:18px;">{{item.trueName}}</span>
              </p>
              <div class="overflow-omit">坐诊科室：{{item.deptName}}-{{item.roomName}}</div>
              <div>等待人数：{{item.waitNum}}</div>
              <div>剩余号源：{{item.remain}}</div>
              <div>总 人 次：{{item.alreadyNum}}</div>
            </div>
          </div>
          <div class="card-footer">
            <div @click="onDetail(item)">登记详情</div>
            <div @click="onOpenOperate(item)">登记/激活</div>
          </div>
        </div>
      </el-col>
    </el-row>
    <div v-if="tableList.length == 0" style="color:#999;padding:10px 0;text-align:center;">
      <i class="iconfont iconwushuju" style="font-size:40px;"></i>
      <div>暂无数据</div>
    </div>
    <br>
    <pager v-model="pager" @change-pagenum="getData"></pager>
    <userOperate v-model="dialogSK" :dateDay="form.dateDay" :curItem="curItem"></userOperate>
    <registerRecord v-model="registerRecord" :curItem="curItem"></registerRecord>
  </section>
</template>
<script>
export default {
  components: {
    deptSearch: () => import("@/pages/_com/deptSearch.vue"),
    doctorSearch: () => import("@/pages/_com/doctorSearch.vue"),
    userOperate: () => import("./_com/userOperate.vue"),
    registerRecord: () => import("./_com/registerRecord.vue")
  },
  data() {
    return {
      curItem: "",
      registerRecord: false,
      form: {
        deptId: "",
        doctorId: "",
        days: 1,
        type: 1,
        dateDay: ""
      },
      dialogSK: false,
      curDate: new Date(),
      tableList: [],
      pager: { pageSize: 12, pageNum: 1, total: 0 }
    };
  },
  created() {
    let th = this;
    th.getData();
  },
  methods: {
    //刷卡
    onOpenOperate(obj) {
      let th = this;
      th.curItem = obj;
      th.dialogSK = true;
    },
    //查看详情
    onDetail(obj) {
      let th = this;
      th.curItem = obj;
      th.registerRecord = true;
    },
    getData(type) {
      let th = this;
      th.form.dateDay = th.$utils.FormatTime(
        "yyyy-MM-dd",
        th.curDate.getTime()
      );
      if (type == -1) {
        th.pager.pageNum = 1;
        th.pager.total = 0;
      }
      let j = {};
      Object.assign(j, th.pager);
      Object.assign(j, th.form);
      th.showLoading();
      th.$api.getDoctorScheduleListByDate(j).then(res => {
        if (res.executed) {
          th.tableList = res.dataBody.list;
          th.pager.total = res.dataBody.total;
        }
        th.showLoading(false);
      });
    },
    onChangeDept() {
      let th = this;
      th.form.doctorId = "";
      th.$nextTick(function() {
        th.$refs["doctorSearch"].getData();
      });
    }
  }
};
</script>
<style lang="scss">
@import "../_css/reserve.scss";
</style>